//
//  AppDelegate.m
//  coachmanage
//
//  Created by 众拳科技 on 2018/3/5.
//  Copyright © 2018年 众拳科技. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

/**
 配置高德
 */
- (void)configureAPIKey
{
    
//    [AMapServices sharedServices].apiKey = @"9de43b8d17e25636ec99c78784351e34";
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    [self.window makeKeyAndVisible];
    
    self.window.backgroundColor = [UIColor whiteColor];
    
    
    //容错措施
    [AvoidCrash makeAllEffective];
    
    NSArray *noneSelClassStrings = @[
                                     @"NSString"
                                     ];
    
    [AvoidCrash setupNoneSelClassStringsArr:noneSelClassStrings];
    
    [self configureAPIKey];
    
    //隐藏状态栏
    [application setStatusBarHidden:YES];
    
    IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
    //控制整个功能是否启用。
    manager.enable = YES;
    //控制点击背景是否收起键盘
    manager.shouldResignOnTouchOutside = YES;
    manager.enableAutoToolbar = YES;
    
    //设置状态栏背景颜色
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    
    self.window.rootViewController = [[MyTabBarViewController alloc] init];
    
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    
    //友盟
//    [self setupUMengSocial];
    
    //进入主页面
    BOOL isLogin = [userDefault boolForKey:@"isLogin"];
    
    if (isLogin) {
        
        BOOL isCompleteInfo = [userDefault boolForKey:@"isCompleteInfo"];
        
        //已经登录并且第一次已经完善了品牌信息和场地信息
//        if (isCompleteInfo) {
//            
//            MyTabBarViewController *myTabVC = [[MyTabBarViewController alloc] initWithCompleteInfo:YES];
//            
//            self.window.rootViewController = myTabVC;
//            
//           
//        }
//        else{
//            
//            self.window.rootViewController = [[MyTabBarViewController alloc] init];
//            
//            
//            __weak typeof(self)weakSelf = self;
//            
//            CZQShopBandChoseView *sourceAlertView = [[CZQShopBandChoseView alloc] init];
//            
//            
//            
//            sourceAlertView.urlString = Get_Brand;
//            
//            
//            sourceAlertView.commitBlock = ^(NSString *str) {
//                
//                CZQShopBandChoseView *shop = [[CZQShopBandChoseView alloc] init];
//                
//                NSMutableDictionary *param = [NSMutableDictionary dictionary];
//                
//                
//                shop.pandID = str;
//                
//                shop.urlString = [NSString stringWithFormat:@"%@%@",Get_ShopList,str];
//                
//                
//                shop.commitBlock = ^(NSString *str) {
//                    
//                    
//                    
//                };
//                
//                [shop showWithAnimation];
//                
//                
//            };
//            
//            [sourceAlertView showWithAnimation];
//        }
        
        //登录腾讯IM
//        [self loginTim];
    }
    else{
        
        self.window.rootViewController = [[MyTabBarViewController alloc] init];
    }
    return YES;
}

+ (instancetype)sharedAppDelegate
{
    return (AppDelegate *)[UIApplication sharedApplication].delegate;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


@end
